import { defineStore } from 'pinia'

/**
 * collapsed 菜单是否展开
 * activeKey 默认选中某个菜单
 * menuType 菜单类型
 * defaultExpandKeys 默认展开的节点
 */
export interface MapState {
  collapsed: Boolean;
  activeKey: string | null,
  menuType: Number,
  defaultExpandKeys: string[]
}


export const menuStore = defineStore('menuStore',{
	state:(): MapState=>{
		return {
			collapsed: true,
			activeKey: null,
			menuType: 1,
			defaultExpandKeys:[]
		}
	},
	getters:{},
	actions:{
		setCollapsed(collapsed: Boolean){
			this.collapsed = collapsed
		},
		setActiveKey(activeKey: string | null, defaultExpandKeys:string[]){
			this.activeKey = activeKey
			this.defaultExpandKeys = defaultExpandKeys
		},
		setMenuType(menuType: Number){
			this.menuType = menuType
		},
	},
	persist: true
})